<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model:value='n1'>+
        <input type="text" v-model:value='n2'>*
        <input type="text" v-model:value='n3'>={{result}}
    </div>
  
    <script src="vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            // template:`
 
            
            // `,

            data:function () {
                // return {msg:{text:''}

                return {n1:'',n2:'',n3:'1'}
            }
            
            ,


            //when this. any property change,then will trigeer the computed
            computed:{
                result:function(){
                    return (Number(this.n1)+Number(this.n2)*Number(this.n3));
                }
            },
            watch:{
                // msg:function(newval,oldval){
                //     if(newval=='love'){
                //         alert(newval);
                //     }

                // }
                //复杂数据类型要开启
                msg:{
                    handler(newval,oldval) {
                   if(newval.text=='love'){
                       alert(newval.text);
                   } 
                },
                deep:true
            }
            }
        })
    </script>
</body>
</html>